CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(SGPYCC)
ADD_SUBDIRECTORY(src bin)
SUBDIRS(icons)

SET(VERSION "0.2.6")

IF(NOT DEFINED SHARE_INSTALL_PREFIX)
  SET(PKGDATADIR "${CMAKE_INSTALL_PREFIX}/share/ibus-sogoupycc")
ELSE()
  SET(PKGDATADIR "${SHARE_INSTALL_PREFIX}/ibus-sogoupycc")
ENDIF()

CONFIGURE_FILE(sogoupycc.xml.template sogoupycc.xml)
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)

ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/sogoupycc.xml DESTINATION share/ibus/component)
INSTALL(FILES config.lua DESTINATION ${PKGDATADIR})
INSTALL(PROGRAMS fetcher DESTINATION ${PKGDATADIR})
